package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import java.util.Map;

public class MainActivity extends AppCompatActivity {
    private EditText et_user;
    private EditText et_password;
    private Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        et_user=(EditText)findViewById(R.id.et_number);
        et_password=(EditText)findViewById(R.id.et_password);
        btn=(Button)findViewById(R.id.btn_login);
        //1、保存
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //准备数据
                String name=et_user.getText().toString().trim();
                String password=et_password.getText().toString().trim();
                SPSaveQQ.saveUserInfo(MainActivity.this,name,password);
            }
        });
        //2、读取
        Map<String,String> m=SPSaveQQ.getUserInfo(this);
        String name=m.get("username");
        String password=m.get("userpassword");
        et_user.setText(name);
        et_password.setText(password);
    }
}
